import jdk.jfr.StackTrace;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBC_PrepareStatement {

    public static void main(String[] args) {

        Connection connection = null;
        PreparedStatement ps = null;
        ResultSet resultSet = null;
        try {
            connection = JDBCUtils.getConnection();

            String sql = "select * from employee";

            ps = connection.prepareStatement(sql);

            resultSet = ps.executeQuery();

            while (resultSet.next()) {
                String name = resultSet.getString("name");
                String gender = resultSet.getString("gender");
                System.out.println("姓名：" + name + " 性别：" + gender);
            }

            JDBCUtils.close(connection,ps);
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
